package org.liuyunfeng.web;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.liuyunfeng.domain.ExcellentEnterpriseSelectionApplication;
import org.liuyunfeng.service.ExcellentEnterpriseSelectionService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: TanJingyu
 * @create: 2022-01-05 16:42
 **/
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "activity/excellentEnterpriseSelection", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ExcellentEnterpriseSelectionController {
    private final ExcellentEnterpriseSelectionService service;

    /**
     * 保存/修改申请信息
     */
    @RequestMapping("/save")
    public Response<ExcellentEnterpriseSelectionApplication> save(ExcellentEnterpriseSelectionApplication application) {
        return Response.ok(service.save(application), "success");
    }

    /**
     * 用户是否提交成功评选资料
     */
    @RequestMapping("/submitStatus")
    public Response<ExcellentEnterpriseSelectionApplication> submitStatus(@RequestParam("openid") String openId) {
        return Response.ok(null, "");
    }

    /**
     * 用户是否已经参与活动
     */
    @RequestMapping("/joinStatus")
    public Response<Boolean> joinStatus(@RequestParam("openid") String openId) {
        return Response.ok(null, null);
    }

    /**
     * 活动咨询，人工服务的企业微信二维码
     * @return 二维码链接
     */
    @RequestMapping("/qrCode")
    public Response<String> qrCode() {
        return Response.ok(null, null);
    }


    @Getter
    @Setter
    @Accessors(chain = true)
    public static class Response<T> {
        private T data;
        private Integer code;
        private String msg;

        public static <T> Response<T> ok(T data, String msg) {
            return new Response<T>()
                    .setCode(200)
                    .setData(data)
                    .setMsg(msg);
        }

        public static Response<Object> error(Integer code, String msg) {
            return new Response<>()
                    .setCode(code)
                    .setMsg(msg);
        }
    }
}

    